﻿using System;

namespace CSharpDelegate
{
    class Program
    {
        //声明一个委托指向一个函数
        public delegate void SayHi(string name);


        static void Main(string[] args)
        {
            //SayHi del = SayHiChinese;//new SayHi(SayHiEnglish);
            //del("张三");
            //Console.ReadKey();

            //Test("张三", SayHiChinese);
            //Console.ReadKey();

            //SayHi del = delegate (string name)
            //{
            //    Console.WriteLine("你好" + name);
            //};
            //del("张三");

            SayHi del = (string name) => { Console.WriteLine("你好" + name); };
            del("张三");

            //SayHiChinese("张三");
        }

        public static void Test(string name, SayHi del)
        {
            del(name);
        }

        public static void SayHiChinese(string name)
        {
            Console.WriteLine("你好！" + name);
        }
        public static void SayHiEnglish(string name)
        {
            Console.WriteLine("Hello!" + name);
        }
    }
}
